﻿<table width="100%" cellpadding="0" cellspacing="0">
	<tr><td height="5"></td></tr><?php 
	//So luong co quan hanh chinh lay duoc
	$v_number_of_agency = sizeof($arr_all_agency);
	$v_number_of_cate = sizeof($arr_all_cate);
	if($v_number_of_agency > 0){  //(*) ?>
		<tr class="page_title">
			<td colspan="3"><?php echo CONST_AF_SEARCH_BY_AGENCY_LABEL; ?></td>
		</tr>
		<tr><td height="5"></td></tr><?php			
			$current_pos=0; // vi tri hien thoi 
			for($row_index =0; $row_index< $v_number_of_agency; $row_index++){//(**)
				$v_agency_name= $arr_all_agency[$row_index]['1'];
				$v_agency_id= $arr_all_agency[$row_index]['0'];
				$v_af_num= $arr_all_agency[$row_index]['2'];
				$v_cate_num= $arr_all_agency[$row_index]['3'];
				$v_agency_url = "index.php?fuseaction=DISPLAY_ALL_CATE_BY_AGENCY&v_session=".$v_session."&agency_id=" . $v_agency_id ;
				?>				
				<tr class="category_link"> 
					<td colspan="3">						
						<a class="category_link" href="<?php echo $v_agency_url;?>"><?php echo $v_agency_name." (".$v_af_num.")";?></a>
					</td>
				</tr>				
				<?php
					$v_left_agency_id = $arr_all_cate[$current_pos]['0'];
					while (($v_left_agency_id==$v_agency_id)&&($current_pos<$v_number_of_cate)){
						$v_left_category_id = $arr_all_cate[$current_pos]['1'];
						$v_left_cate_name = $arr_all_cate[$current_pos]['2'];
						$v_left_num_af = $arr_all_cate[$current_pos]['3'];
						$v_left_cate_url = "index.php?fuseaction=DISPLAY_ALL_AF_BY_CATE&v_session=".$v_session."&category_id=" . $v_left_category_id . "&agency_id=".$v_agency_id;
				 		$current_pos = $current_pos+1;
						if($current_pos<$v_number_of_cate){
							$v_left_agency_id = $arr_all_cate[$current_pos]['0'];					
						}
				?>					
					<tr > 
						<td>
						<img src="<?php echo $_ISA_IMAGE_URL_PATH?>open.gif" >
							<a href="<?php echo $v_left_cate_url;?>"><?php echo $v_left_cate_name;?></a><? echo " (".$v_left_num_af.")";?>
						</td>
					</tr>
					<?php 
					}	//Dong while 
					if ($v_cate_num>$v_category){
					?>
					<tr class="see_detail_link">
						<td align="right" width="100%" style="padding-right:5pt; ">
							<a class="see_detail_link" href="<?php echo $v_agency_url;?>"><?php echo CONST_SEE_DETAIL_LABEL;?></a>
						</td>	
					</tr>
					<?php
					}//Dong if
					?>
			<tr><td height="5"></td></tr>
					<?php
			}//Vong for (**)
	} //(*)
	else
		echo CONST_NO_AGENCY_MESSAGE;
	?>	
</table>
<table>
<tr>
	<col width="5%"><col width="95%">
<td align="center" class="normal_label">
<?

if ($v_total_agency_count  > $v_limit) 
{//(*)
if ($page == 1)  
	echo "<img src=" . $_ISA_IMAGE_URL_PATH . "d-arrow-left.jpg  align=center>"; 
else            
	echo "<a href=\"index.php?fuseaction=DISPLAY_ALL_AF_BY_ALL_AGENCY&v_session=".$v_session."&page=".($page - 1). "\">". "<img src=" . $_ISA_IMAGE_URL_PATH . "arrow-left.jpg  align=center>" . "</a>";

for ($i = 1; $i <= $pager->numPages; $i++) { 
	echo " | "; 
	if ($i == $pager->page)
		echo $i; 
	else 
		 echo "<a href=\"index.php?fuseaction=DISPLAY_ALL_AF_BY_ALL_AGENCY&v_session=".$v_session."&page=".$i . "\">". $i."</a>";
    }//dong for

if ($page == $pager->numPages) 
	echo " | ". "<img src=" . $_ISA_IMAGE_URL_PATH . "d-arrow-right.jpg align=center>"; 
else            
	echo " | ". "<a href=\"index.php?fuseaction=DISPLAY_ALL_AF_BY_ALL_AGENCY&v_session=".$v_session."&page=".($page + 1) . "\">" . "<img src=" . $_ISA_IMAGE_URL_PATH . "arrow-right.jpg align=center>" . "</a>";
}

?>
</td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
	<tr><td>&nbsp;</td></tr>
	<tr style="display:none ">
		<td align="center"><a class="normal_button" href="<?php echo $_URL_BACK?>"><?php echo _CONST_BACK_BUTTON; ?></a>
		</td>
	</tr>
</table>
